﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.protocolinfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int pid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(pid);
				}
			}
		}
			
	private void ShowInfo(int pid)
	{
		lcs.BLL.protocolinfo bll=new lcs.BLL.protocolinfo();
		lcs.Model.protocolinfo model=bll.GetModel(pid);
		this.lblpid.Text=model.pid.ToString();
		this.txtsid.Text=model.sid.ToString();
		this.txtmbm.Text=model.mbm;
		this.txtmprice.Text=model.mprice.ToString();
		this.txtpmark1.Text=model.pmark1;
		this.txtpmark2.Text=model.pmark2;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtsid.Text))
			{
				strErr+="中标供应商格式错误！\\n";	
			}
			if(this.txtmbm.Text.Trim().Length==0)
			{
				strErr+="中标物料不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtmprice.Text))
			{
				strErr+="中标价格格式错误！\\n";	
			}
			if(this.txtpmark1.Text.Trim().Length==0)
			{
				strErr+="pmark1不能为空！\\n";	
			}
			if(this.txtpmark2.Text.Trim().Length==0)
			{
				strErr+="pmark2不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int pid=int.Parse(this.lblpid.Text);
			int sid=int.Parse(this.txtsid.Text);
			string mbm=this.txtmbm.Text;
			decimal mprice=decimal.Parse(this.txtmprice.Text);
			string pmark1=this.txtpmark1.Text;
			string pmark2=this.txtpmark2.Text;


			lcs.Model.protocolinfo model=new lcs.Model.protocolinfo();
			model.pid=pid;
			model.sid=sid;
			model.mbm=mbm;
			model.mprice=mprice;
			model.pmark1=pmark1;
			model.pmark2=pmark2;

			lcs.BLL.protocolinfo bll=new lcs.BLL.protocolinfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
